import { createElement, HTMLAttributes, type FC } from 'react';
import classNames from 'classnames';

import { itemContentDefaultProps } from './defaultProps';
import type { ItemContentOptions } from './type';

export interface ItemContentProps extends ItemContentOptions, HTMLAttributes<HTMLDivElement> {}

const ItemContent: FC<ItemContentProps> = (props) => {
  const { className, aligned, children, forwardedRef, ...itemContentProps } = props;

  return createElement(
    'div',
    { ref: forwardedRef, className: classNames(aligned, { aligned }, 'content', className), ...itemContentProps },
    children,
  );
};

ItemContent.displayName = 'ItemContent';
ItemContent.defaultProps = itemContentDefaultProps;

export default ItemContent;
